﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Template.Master" Inherits="System.Web.Mvc.ViewPage<JLL.China.Web.Areas.Portal.Models.BannerModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <%--<!--  start page-heading -->
    <div id="page-heading">
        <h1>
            Manage Article: Create new
        </h1>
    </div>--%>
    <div class="menu-nav">
        <%Html.RenderPartial("Side");%>
    </div>
    <!-- end page-heading -->
    <table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
        <tr>
            <th rowspan="3" class="sized">
                <img src="<%=Url.Content("~/Content/images/shared/side_shadowleft.jpg")%>" width="20"
                    height="300" alt="" />
            </th>
            <th class="topleft">
            </th>
            <td id="tbl-border-top">
                &nbsp;
            </td>
            <th class="topright">
            </th>
            <th rowspan="3" class="sized">
                <img src="<%=Url.Content("~/Content/images/shared/side_shadowright.jpg")%>" width="20"
                    height="300" alt="" />
            </th>
        </tr>
        <tr>
            <td id="tbl-border-left">
            </td>
            <td>
                <!--  start content-table-inner ...................................................................... START -->
                <div id="content-table-inner">
                    <% Html.RenderPartial("Measage");%>
                    <%Html.RenderPartial("Form", Model); %>
                </div>
                <!--  end table-content  -->
                <!-- show banner-->
                <div class="image_area" id="mediaphoto_content">
                    <b>Home Banners</b>
                    <div class="list">
                        <% if (this.Model.Banners.Count > 0)
                           {%>
                        <ul id="list1">
                            <%
                                string ImagePath = Url.Content("~/") + "Media/Banner/Home/";

                                foreach (var item in this.Model.Banners)
                                {
                            %>
                            <li data-itemid='<%= item.Banner_ID %>'>
                                <div>
                                    <span><b> 
                                        <%= item.Title %></b></span>
                                </div>
                                <div>
                                    <% 
                                        if (string.IsNullOrEmpty(item.BannerUrl))
                                        {
                                    %>
                                    <img class="img_photo" src="<%= Url.Content("~/") %>Content/images/no_img_default.png" />
                                    <% }
                                   else
                                   {%>
                                    <img class="img_photo" src="<%= Url.Content("~/") %>Media/Banner/Home/<%=item.BannerUrl %>"
                                        alt="<%=item.Title %>" />
                                    <% } %>
                                </div>
                                <div class="tools">
                                    <div class="t-left">
                                        &nbsp;</div>
                                    <div class="t-center">
                                        <a class="statuslink info-tooltip" href="<%=Url.Content("~/")+ViewData["now_controller"]%>Index/<%=item.Banner_ID%>"
                                            title="Edit">
                                            <img src="<%=Url.Content("~/Content/")%>images/File_edit.png" name="" /></a>
                                        <a class="removelink remove-btn info-tooltip" href="<%=Url.Content("~/")+ViewData["now_controller"]%>Delete/<%=item.Banner_ID%>"
                                            title="Delete">
                                            <img src="<%=Url.Content("~/Content/")%>images/icon_delete.png" /></a> <a class="fancybox-button info-tooltip"
                                                rel="fancybox-button" href="<%=ImagePath+item.BannerUrl%>" title="Zoom this image">
                                                <img src="<%=Url.Content("~/Content/")%>images/icon-zoom.png" /></a>
                                    </div>
                                    <div class="t-right">
                                        &nbsp;</div>
                                </div>
                            </li>
                            <%}     
                            %>
                        </ul>
                        <%}
                           else
                           { %>
                        <br />
                        <br />
                        <h4 style='color: #92B22C;'>
                            No banners at the moment</h4>
                        <%} %>
                        <br style="clear: both;" />
                    </div>
                    <!--#list-->
                </div>
            </td>
            <td id="tbl-border-right">
            </td>
        </tr>
        <tr>
            <th class="sized bottomleft">
            </th>
            <td id="tbl-border-bottom">
                &nbsp;
            </td>
            <th class="sized bottomright">
            </th>
        </tr>
    </table>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="CSS" runat="server">
    <link href="<%=Url.Content("~/Scripts/qtip2/jquery.qtip.min.css") %>" rel="stylesheet"
        type="text/css" />
    <link href="<%=Url.Content("~/Scripts/jquery.validation/validationEngine.jquery.css")%>"
        rel="stylesheet" type="text/css" />
    <link href="<%=Url.Content("~/Content/css/mod-listing.css")%>" rel="stylesheet" type="text/css" />
    <link href="<%=Url.Content("~/Scripts/chosen/chosen.css")%>" rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="JS" runat="server">

    <script src="<%=Url.Content("~/Scripts/jquery.validation/jquery.validationEngine-en.js")%>"
        type="text/javascript"></script>

    <script src="<%=Url.Content("~/Scripts/jquery.validation/jquery.validationEngine.js")%>"
        type="text/javascript"></script>

    <script src="<%=Url.Content("~/Scripts/chosen/chosen.jquery.min.js")%>" type="text/javascript"></script>

    <script src="<%=Url.Content("~/Scripts/qtip2/jquery.qtip.min.js")%>" type="text/javascript"></script>

    <script src="<%=Url.Content("~/Scripts/jquery.validation/jquery.validate.js")%>"
        type="text/javascript"></script>

    <script src="<%=Url.Content("~/Scripts/ckeditor/ckeditor.js")%>" type="text/javascript"></script>

    <script type="text/javascript" src="<%=Url.Content("~/Scripts/ckeditor/adapters/jquery.js")%>"></script>

    <script type="text/javascript" src="<%= Url.Content("~/Scripts/Run.js")  %>"></script>

    <script type="text/javascript" src="<%= Url.Content("~/Scripts/jquery.dragsort.js")  %>"></script>

    <script type="text/javascript">

        function checkForm() {
            $(document).ready(function() {

                if ($('#title').val().length > 3) {
                    $('#title_validate').val('ok');
                }
                else {
                    $('#title_validate').val('');
                }

                if ($('#contentID').val().length > 3) {
                    $('#content_validate').val('ok');
                }
                else {
                    $('#content_validate').val('');
                }


                if ($('#title_local').val().length > 3) {
                    $('#title_local_validate').val('ok');
                }
                else {
                    $('#title_local_validate').val('');
                }

                if ($('#content_local').val().length > 3) {
                    $('#content_local_validate').val('ok');
                }
                else {
                    $('#content_local_validate').val('');
                }

            });

        }



        $(document).ready(function() {

            $('.ckeditors').ckeditor();

            $("#list1, #list2").dragsort({
                dragSelector: "div",
                dragBetween: true,
                dragEnd: saveOrder,
                placeHolderTemplate: "<li class='placeHolder'><div></div></li>"
            });

            function saveOrder() {
                $("#content-outer").showLoading();
                var data = $("#list1 li").map(function() { return $(this).data("itemid"); }).get();
                
                $.ajax({
                    url: BASE_URL + "Portal/HomeBanner/SaveOrder/" + data,

                    success: function(result) {
                        if(result=="OK") {
                            $("#content-outer").hideLoading();
                            jSuccess(
		                                '<div class="msgnotify"><b>Update order successfully</b></div>',
		                                {
		                                    autoHide: true, // added in v2.0
		                                    HorizontalPosition: 'center',
		                                    VerticalPosition: 'top'
		                                });   
                        }
                    }
                });
            };
            //fancy box
            $(".fancybox-button").fancybox({
                prevEffect: 'none',
                nextEffect: 'none',
                closeBtn: false,
                helpers: {
                    title: null,
                    buttons: {}
                }
            });
            //qtip
            $('a[title]').qtip();




            //prompt for delete button
            $('.remove-btn').click(function(e) {
                e.preventDefault(); //prevent default action for anchor
                var self = this;
                Confirm("Confirm removed the selected record?", function(yes) {
                    if (yes) {
                        $("#content-outer").showLoading();
                        window.location = self.href;
                    }
                });
            });

            jQuery("#formID").validationEngine({
                prettySelect: true,
                useSuffix: "_chzn"
                //promptPosition : "bottomLeft"
            });

            $(".chzn-nosearch").chosen({ disable_search_threshold: 3 });
            //End Data
            $(".chosen-select").chosen({
                allow_single_deselect: true
            });

        });
    </script>

</asp:Content>
